package 剑指offer.Month7_07.day18;

public class 调整数组顺序使得奇数位于偶数之前 {
    public int[] reOrderArrayTwo (int[] array) {
        // write code here
        if(array.length == 1 || array == null) return array;
        int i = 0;
        int j = array.length - 1;
        while(i < j){
            while(i < j && array[i] % 2 != 0){
                i++;
            }
            while(i < j && array[j] % 2 == 0){
                j--;
            }
            if(i < j){
                int tmp = array[i];
                array[i] = array[j];
                array[j] = tmp;
            }
        }
        return array;
    }
}
